﻿using System;

using Wicresoft.Framework.Organization;
using MaLu.BusiLogic;
using MaLu.Common;
using System.Data;
using MaLu.Data;

namespace MaluJg.web.ProjectFund
{
    public partial class AddItem : ProjectPage
    {
        public Guid DepartmentID
        {
            get
            {
                if (Request["DepartmentID"] != null)
                    return new Guid(Request["DepartmentID"]);
                return Guid.NewGuid();
            }
        }

     

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (ProjectID != Guid.Empty)
                {
                   
                    DataTable dt = SqlHelper.Instance.ExecuteDataTable(Provider, "select name from Project where id ='" + ProjectID.ToString() + "'");
                    if (dt.Rows.Count > 0)
                    {
                        tbName.Text = dt.Rows[0][0].ToString().Replace("''","'");
                    }
                }
            }
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            Department d = Wicresoft.Framework.Organization.OrganizationHelper.GetDepartmentInfo(DepartmentID);

            BLProject.SaveProject(Provider, ProjectID, tbName.Text.Trim().Replace("'", "''"), d.ID, d.Name, d.DisplayName);

            ClientScript.RegisterStartupScript(this.GetType(), "Close", "<script>window.close();</script>");
        }
    }

}
